Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mark main and serverAssert as weak symbols to be overridden #1232

Open
wants to merge 1 commit into
base: unstable
Choose a base branch
from

Conversation

madolson
Copy link
Member

@madolson madolson commented Oct 25, 2024

At some point unit tests stopped building on MacOS because of duplicate symbols. I had originally solved this problem by using a flag that overrides symbols, but the much better solution is to mark the duplicate symbols as weak and they can be overridden during linking. (Symbols by default are strong, strong symbols override weak symbols)

I also added macos unit build to the CI, so that this doesn't silently break in the future again.

@madolson madolson changed the title Mark main and debug as weak symbols to be overridden Mark main and serverAssert as weak symbols to be overridden Oct 25, 2024
Copy link

codecov bot commented Oct 25, 2024

Codecov Report

Attention: Patch coverage is 50.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 70.55%. Comparing base (4be09e4) to head (8e5a6ae).

Files with missing lines Patch % Lines
src/debug.c 0.00% 1 Missing ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##           unstable    #1232      +/-   ##
============================================
+ Coverage     70.54%   70.55%   +0.01%     
============================================
  Files           114      114              
  Lines         63144    63144              
============================================
+ Hits          44543    44554      +11     
+ Misses        18601    18590      -11     
Files with missing lines Coverage Δ
src/server.c 87.70% <100.00%> (ø)
src/debug.c 53.05% <0.00%> (ø)

... and 13 files with indirect coverage changes

Copy link
Contributor

@zuiderkwast zuiderkwast left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good idea!

@@ -83,7 +83,7 @@ jobs:
steps:
- uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1
- name: make
run: make -j3 SERVER_CFLAGS='-Werror'
run: make all-with-unit-tests -j3 SERVER_CFLAGS='-Werror'
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

make flags before the target seems more common style. We do that in other places.

Suggested change
run: make all-with-unit-tests -j3 SERVER_CFLAGS='-Werror'
run: make -j3 all-with-unit-tests SERVER_CFLAGS='-Werror'

@@ -6810,7 +6810,7 @@ serverTestProc *getTestProcByName(const char *name) {
}
#endif

int main(int argc, char **argv) {
__attribute__((weak)) int main(int argc, char **argv) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Add a comment about why we add this attribute on main?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants